package com.example.snackbar;

import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import android.os.Bundle;

import com.example.snackbar.Adapter.RecAdapter;

import java.util.ArrayList;

public class RecycleView extends AppCompatActivity {
    RecyclerView recycler_view;
    ArrayList<Message2> list = new ArrayList<>();
   String[] message = {"讲述人","电脑","首页"};
   int[] icon = {R.drawable.talk,R.drawable.computer,R.drawable.first};
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_recycle_view);
        recycler_view = findViewById(R.id.recycler_view);
        initView();
    }

    public void initView(){
        LinearLayoutManager layoutManager = new LinearLayoutManager(this);
        layoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);
        setList();
        recycler_view.setLayoutManager(layoutManager);
        recycler_view.setAdapter(new RecAdapter(list));
    }

    public void setList(){
        for (int k=0;k<10;k++){
            for (int i =0;i<message.length;i++){
                Message2 message2 = new Message2(message[i],icon[i]);
                list.add(message2);
            }
        }
    }

}